<?php

/**
 * MemberAddress form base class.
 *
 * @method MemberAddress getObject() Returns the current form's model object
 *
 * @package    Wildlive
 * @subpackage form
 * @author     Maximilian Lenkeit <dev@lenki.com>
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseMemberAddressForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'ID'                      => new sfWidgetFormInputHidden(),
      'address_id'              => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Address'), 'add_empty' => false)),
      'personal_member_data_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('PersonalMemberData'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'ID'                      => new sfValidatorChoice(array('choices' => array($this->getObject()->get('ID')), 'empty_value' => $this->getObject()->get('ID'), 'required' => false)),
      'address_id'              => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Address'))),
      'personal_member_data_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('PersonalMemberData'), 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'MemberAddress', 'column' => array('ID')))
    );

    $this->widgetSchema->setNameFormat('member_address[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'MemberAddress';
  }

}
